package it.asvp.asvp_portal.data.entity.message;


import static javax.persistence.GenerationType.IDENTITY;
import it.asvp.asvp_portal.data.entity.domain.BaseEntity;
import it.asvp.asvp_portal.data.entity.member.Member;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name = "message", catalog = "asvp_db")
public class Message extends BaseEntity {

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_member", nullable = false)
	private Member member;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_topic", nullable = false)
	private Topic topic;
	
	@Column(name = "content", nullable = false, length = 1000)
	private String content;
	
	public Message() {
	}

	public Message(Member member, Topic topic, String content, Date createdOn,
			Date lastUpdate) {
		this.member = member;
		this.topic = topic;
		this.content = content;
		this.createdOn = createdOn;
		this.lastUpdate = lastUpdate;
	}

	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	
	public Topic getTopic() {
		return this.topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}
}
